package com.atguigu.gmall.mq.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.service.RabbitService;
import com.atguigu.gmall.mq.config.DeadLetterConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: 封捷
 * @create-date: 2022/9/11 9:01
 */
@RestController
public class DeadLetterSendController {

    @Autowired
    private RabbitService rabbitService;

    @GetMapping("/mq/test/send/stupid/message/to/dead/letter")
    public Result<Void> sendMessageToDeadLetter() {

        rabbitService.sendMessage(DeadLetterConfig.EXCHANGE_NORMAL_NAME, DeadLetterConfig.ROUTING_KEY_NORMAL_NAME, "hello,you stupid 222");

        System.out.println("[Send Message]" + new SimpleDateFormat("HH:mm:ss").format(new Date()));

        return Result.ok();
    }

}
